home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11095 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: cypher.3do.com!user
  2. From: tsw@3do.com (Tom Watson)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Q about the float point format......
  5. Date: Thu, 21 Mar 1996 14:42:17 -0800
  6. Organization: The 3DO Corporation
  7. Distribution: world
  8. Message-ID: <tsw-2103961442170001@cypher.3do.com>
  9. References: <s3032089.15.314E68DD@sparc13.ncu.edu.tw> <4imhl7$jcf@news.xs4all.nl>
  10. NNTP-Posting-Host: cypher.3do.com
  11.  
  12. In article <4imhl7$jcf@news.xs4all.nl>, falstaff@xs4all.nl (Falstaff) wrote:
  13.  
  14. > s3032089@sparc13.ncu.edu.tw (Alexander PeaceLand) writes:
  15. > >   Could I dynamicly set the digits after the float POINT?
  16. > >   In other word... I use printf to print the float point number
  17. > >                    like 123.456789 but in the other time i only 
  18. > >                    want to print 123.456 or 123.4 
  19. > >                    How shall I do? Thanks! :)
  20. >    i=3;  /* or whatever */
  21. >    printf("%.*f",123.456789,i);
  22. > That should work.
  23.  
  24.  
  25. The spirit is willing, the body is weak...
  26.  
  27. Arguments reversed to printf!  The argument for the '*' needs to come
  28. first, so it should be:
  29.    i=3;  /* or whatever */
  30.    printf("%.*f", i, 123.456789);
  31. The idea is good though!!
  32.  
  33. Yes, I tried it with my compiler!!
  34.  
  35. -- 
  36. Tom Watson
  37. tsw@3do.com         (Home: tsw@johana.com)
  38.